import Vue from 'vue'
// 布局页面
import Layout from './components/layout.vue'
// 首页
import IndexPage from './pages/index.vue'
// 详情
import DetailIndexPage from './pages/detail.vue'
import DetailAnaPage from './pages/detail/analysis.vue'
import DetailCouPage from './pages/detail/count.vue'
import DetailForPage from './pages/detail/forecast.vue'
import DetailPubPage from './pages/detail/publish.vue'
// 订单详情
import OrderListPage from './pages/orderList.vue'

import store from './store'

// 系统自带路由
// import router from './router'

// 路由
import VueRouter from 'vue-router'
// 请求服务端数据
import VueResource from 'vue-resource'

// vuex
// import Vuex from 'vuex'

Vue.config.productionTip = false

// 使用路由
Vue.use(VueRouter)
// 使用VueResource
Vue.use(VueResource)

let router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      component: IndexPage
    },
    {
      path: '/orderList',
      component: OrderListPage
    },
    {
      path: '/detail',
      component: DetailIndexPage,
      /* 如果访问detail，那么重定向 */
      redirect: '/detail/analysis',
      children: [
        {
          path: 'analysis',
          component: DetailAnaPage
        },
        {
          path: 'count',
          component: DetailCouPage
        },
        {
          path: 'forecast',
          component: DetailForPage
        },
        {
          path: 'publish',
          component: DetailPubPage
        }
      ]
    }
  ]
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store: store,
  components: { Layout },
  template: '<Layout/>'
})
